﻿#ifndef PST_THREEDCLOUDMAPSIDEBARSETTINGS_H
#define PST_THREEDCLOUDMAPSIDEBARSETTINGS_H

#include <QWidget>
#include <QScrollArea>
#include <QMouseEvent>
#include <QListView>
#include <QListWidget>
#include <QSize>
#include <QList>
#include <QRect>
#include <QModelIndex>
#include "InfomationGraph3DBasical.h"
#include "ThreeDCloudMapSidebarData.h"

QT_BEGIN_NAMESPACE
namespace Ui
{
    class ThreeDCloudMapSidebarSettings;
};
class QTabWidget;
class QLineEdit;
class QComboBox;
class QListView;
class QVBoxLayout;
class QStandardItem;
QT_END_NAMESPACE

namespace pst
{
    class ThreeDCloudMapSidebarSettings : public QWidget
    {
        Q_OBJECT
    public:
        ThreeDCloudMapSidebarSettings(QWidget* parent = nullptr);
        ~ThreeDCloudMapSidebarSettings();

        void setMainWiondowId(int id);

        QListWidgetItem* addData(InfomationGraph3DBasical* info);

        // void setSlicePositionEnum(const QList<double>& xSliceEnum,
        // const QList<double>& ySliceEnum, const QList<double>& zSliceEnum);
        void updateInfoDataAndInterfaceToUI(ThreeDCloudMapSidebarData* data);
        // 只更新数值，不更新交互（如Enabled）
        void updateInfoValueToUI(ThreeDCloudMapSidebarData* data);
        // 设置控制面板是否可编辑
        void setControlPanelEditable(bool enable);
        void clearControlPlane();
        QListWidget* getCurveNameListWidget();

        // 设置控制面板是否为动画状态，动画状态下不可编辑
        void setControlPlaneToAnimationState(bool isAnimationState);

    private:
        void addTopTabPivotUI();
        void addDataPageUI();
        void addCurveListUI();
        void addDataOptrationUI();
    signals:
        void signal_chosenItemsChanged(const QList<QListWidgetItem*>& itemList);
        void siganl_showHideItemActor(QListWidgetItem* item);
        void siganl_graphNameDoubleClicked(QListWidgetItem* item);
        void signal_updateActorValue(ThreeDCloudMapSidebarData* data);
        void signal_updateOrignalData(ThreeDCloudMapSidebarData* data);
        void signal_deleteChosenGraphs(const QList<QListWidgetItem*>& itemList);
        void signal_getSidebarCurveDataSource(QListWidgetItem* item, QString& dataSource);
        void signal_renameCheck();//重命名结果检查

    public slots:
        void slot_curveNameClicked();
        void slot_itemCheckStateChanged(QListWidgetItem* item);
        void slot_itemDoubleClicked(QListWidgetItem* item);
        //void slot_normalizeClicked(bool checked);
        //void slot_logClicked(bool checked);
        void slot_updateFixedParameter(int index);
        void slot_updateOriginalDataSource(int index);
        void slot_resultDataChanged(int index);
        void on_pushButton_FormulaEditor_clicked();
        void slot_addCustomContextMenu(const QPoint& pos);

        void on_radioButton_Amplitude_clicked();     // 幅度
        void on_radioButton_Phase_clicked();         // 相位
        void on_radioButton_RealPart_clicked();      // 实部
        void on_radioButton_ImaginaryPart_clicked(); // 虚部

        void slot_renameItem();

    private:
        void initConnection();
        // bool computeSlicePositionEnum(const InfomationGraph3DBasical& info);
        // 选择一个图像后 更新其数据到面板上
        void connectSignalsAndSlots();
        void disconnectSignalsAndSlots();
        void hideComponents();
        void updateFixedParameter(int index);
        void updateGroupRadioButtonUI(ThreeDCloudMapSidebarData* data);

    public: // python调用
        void pyCurveNameClicked(QList<int> selectedIndexs);
        void pyUpdateFixedParameter(int index);
        void pyUpdateOriginalDataSource(int index, int showType, int fixedValueIndex, bool isLog, bool isNormalize);
        void pyResultDataChanged(int index);
        void pyDelete3DCloudMap(QString selectedIndexs);
        void pyDataOprationChanged(bool isLoged, bool isNormalized);
        void pyItemCheckStateChanged(int itemIndex, bool visible);

    private:
        int m_mainWindowId;
        Ui::ThreeDCloudMapSidebarSettings* ui;
        // QTabWidget* m_tabWidget;
        /// =============UI组件=============
        /// 第一页内容
        // QWidget* m_page1CentralWidget;
        // QVBoxLayout* _page1Layout;
        int _titleFontSize;
        // QListWidget* m_curveNameListView;            //曲线列表视图
        // QComboBox* m_showTypeComboBox;
        // QComboBox* m_fixedValueComboBox;
        // QComboBox* m_resultDataComboBox;
        // QComboBox* m_categoryTextComboBox;

        QPair<InfomationGraph3DBasical*, QListWidgetItem*> m_currentChosenItem;
        QList<QPair<InfomationGraph3DBasical*, QListWidgetItem*>> m_allAddedDataList;
        QString m_errorMessage;
        // QCheckBox* m_checkBoxlog;
        // QCheckBox* m_checkBoxNormalize;
        // QCheckBox* m_checkBoxMathOp;
        ThreeDCloudMapSidebarData* m_currentItemData;
        QVector<bool> m_enableStatus;
    };

} // namespace pst

#endif
